<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        #fettler_auth_wrapper {
            width:calc(100% - 64px);
            height:100%;
            padding: 32px;
            overflow-x: scroll;
        }
        #fettler_table_list {
            width:100%;
            table-layout:fixed
        }
        #fettler_table_list td {
            white-space: nowrap;
            overflow:hidden;
            text-overflow: ellipsis;
            text-align: center;
            padding:10px 0;
            background-color:#ccc;
            font-size:12px;
        }
    </style>
</head>
<body>
    <div id="fettler_auth_wrapper">
        <input type="hidden" value="${request.contextPath}" id="root" />
        <div class="wrapper_head">
            <h2>师傅管理</h2>
        </div>
        <div id="fettler_table_wrapper">
            <h3 style="margin-bottom:30px">管理员列表: </h3>
            <table id="fettler_table_list" cellspacing="2">
                <tr id="fettler_table_head">
                    <td style="width:5%">Id</td>
                    <td style="width:15%">姓名</td>
                    <td style="width:15%">身份证号码</td>
                    <td style="width:15%">注册时间</td>
                    <td style="width:15%">状态</td>
                    <td style="width:8%">操作</td>
                </tr>
            </table>
            <div style="text-align:center">
                <input type="hidden" id="current_page" value="1" />
                <span onclick="toPage(0)" class="page_button">首页</span>
                <span onclick="toPage(1)" class="page_button">上一页</span>
                <input type="text" id="quick_page" value="1" onblur="quickPage(this)" /><span id="page_count" style="font-size:13px;color:#333"></span>
                <span onclick="toPage(2)" class="page_button">下一页</span>
                <span onclick="toPage(3)" class="page_button">尾页</span>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</body>
<script>
    $("#admin_add_form").submit(function() {
        var username = $("#admin_username").val();
        var password = $("#admin_password").val();
        var password_confirm = $("#admin_password_confirm").val();
        var email = $("#admin_email").val();
        if(username.trim() == "") {
            alert("用户名不能为空!");
            return false;
        }
        if(password.trim() == "") {
            alert("密码不能为空!");
            return false;
        }
        if(password_confirm.trim() == "") {
            alert("密码确认不能为空!");
            return false;
        }
        if(password_confirm != password) {
            alert("两次密码不一致!");
            return false;
        }
        if(email.trim() == "") {
            alert("邮箱地址不能为空!");
            return false;
        }
        $.ajax({
            url: $("#root").val()+"/addAdmin",
            type: "post",
            data: $(this).serialize(),
            dataType: "text",
            success: function(data) {
                if(data == "success") {
                    $("#admin_username").val("");
                    $("#admin_password").val("");
                    $("#admin_password_confirm").val("");
                    $("#admin_email").val("");
                    alert("添加成功!");
                } else {
                    alert("添加失败!");
                    return false;
                }
            },
            error: function(data, type, err) {
                alert(type+"---"+err);
                return false;
            }
        })
    })
</script>
</html>